/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package gui_phone;

import java.awt.Button;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.TextArea;
import java.awt.TextField;
import sip_manager.UA;

/**
 *
 * @author canhchimbang  : Tuan Hiep
 */
public class Phone_gui {
	
    /**
     * utilisé pour imprimer les messages de chat
     */
    public TextArea		text; 
    
    /**
     * utilisé pour saisir les messages de chat
     */
    public static TextField  data;

	public TextField dataconnect; 
    
    /**
     * Frame de la fenetre principale
     */
    public Frame 		frame;

    /**
     * ref directe vers le user agent de communication 
     */
    public static UA ua; 
    
    public Phone_gui() {
	
	// initGui
	frame=new Frame();
	frame.setLayout(new FlowLayout());
	data=new TextField(60);
	frame.add(data);
	text=new TextArea(10,60);
	text.setEditable(false);
	text.setForeground(Color.red);
	frame.add(text);
	
	
// Call button	
	Button call_button = new Button("call");
	call_button.addActionListener(new callListener(this));
	frame.add(call_button);
	
// Answer button	
	Button answer_button = new Button("answer");
	answer_button.addActionListener(new answerListener(this));
	frame.add(answer_button);
// Hangup button	
	Button hangup_button = new Button("hangup");
	hangup_button.addActionListener(new hangupListener(this));
	frame.add(hangup_button);
	
	
	frame.setSize(470,300);
	text.setBackground(Color.black); 
	frame.show();	
    }
    
    public void setHandler(UA ua_para){
    	this.ua = ua_para;
    }
    
    /**
     * Affiche les message  dans le GUI. 
     */
     
    public void Print(String msg) {
    	try {
    		this.text.append(msg+"\n");
    	} catch (Exception ex) {
			ex.printStackTrace();
			return;
	}	
    }

      
}

